/**
 * @ author kunnisser
 * @ date 2018/3/14
 * @ description: 设置mock数据接口
 */

import Axios from 'axios';
import qs from 'qs';

const TIMEOUT = 30e3;
const FILETIMEOUT = 60e3;
const DevApiDomain = 'http://oms.k8s.star-charge.com';
const ProApiDomain = 'https://oms-console.starcharge.com';

const cancelToke = Axios.CancelToken;
const cancelReqs = [];

const getMock = (url) => {
    return (params) => {
        return Axios.get(url, {
        params,
        cancelToken: new cancelToke(function executor (c) {
          cancelReqs.push(c); // 注入cancelToke示例
        }),
        timeout: TIMEOUT,
        headers: {
            'Authorization': window.sessionStorage.getItem('token')
        }
    })
}
}

const postMock = (url) => {
    return (params) => {
       return Axios.post(url, qs.stringify(params), {
        cancelToken: new cancelToke(function executor (c) {
           cancelReqs.push(c);
         }),
        timeout: TIMEOUT,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
            'Authorization': window.sessionStorage.getItem('token')
        }
    });
    }
}

const fileMock = (url) => {
    return (params) => {
        return Axios.post(url, qs.stringify(params), {
            timeout: FILETIMEOUT,
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            }
        });
    }
}

// v1.0.1 api
const buildApi = process.env.doingType === 'buildDev' ? DevApiDomain : ProApiDomain;
const Prefix = process.env.NODE_ENV === 'production' ? buildApi + '/api' : '/api';
const prefixFile = process.env.NODE_ENV === 'production' ? buildApi : 'http://10.9.39.150:8027';
const getUserMenuList = getMock(Prefix + '/user/userMenuList');
const getPermissionList = getMock(Prefix + '/right/permissionList');
const editPermission = postMock(Prefix + '/right/editPermission');
const deletePermission = postMock(Prefix + '/right/delPermission');
const getSmsGroupList = getMock(Prefix + '/sms/getSmsGroupList');
const getSmsInfoList = getMock(Prefix + '/sms/getSmsInfoList');
const getRoleList = getMock(Prefix + '/right/roleList');
const editRole = postMock(Prefix + '/right/editRole');
const deleteRole = postMock(Prefix + '/right/delRole');
const addSmsGroupInfo = postMock(Prefix + '/sms/addSmsGroupInfo');
const sendSmsByGroupId = postMock(Prefix + '/sms/sendSmsByGroupId');
const getUserList = getMock(Prefix + '/user/userList');
const getDDuserList = getMock(Prefix + '/user/ddUserList');
const addUser = postMock(Prefix + '/user/addUser');
const distributeRole = postMock(Prefix + '/right/distributeRole');

// v1.1.0 api
const exchangeCode = postMock(Prefix + '/scUser/userIdAndPhoneChange');
const fetchMap = getMock(Prefix + '/station/findStubGroupList');
const chargingApplication = postMock(Prefix + '/scUser/chargingApplication');
const processChargeNumApply = postMock(Prefix + '/scUser/processChargeNumApply');
const errorCorrection = postMock(Prefix + '/station/errorCorrection');
const estimateManagment = postMock(Prefix + '/interaction/estimateManagment');
const buildingApply = postMock(Prefix + '/station/buildingApply');
const processed = postMock(Prefix + '/station/processed');
const deleteCommend = postMock(Prefix + '/interaction/delete');
const replyCommend = postMock(Prefix + '/interaction/reply');
// 电桩列表查询
const findStubList = postMock(Prefix + '/station/findStubList');
// 私桩列表查询
const findPrivateStubList = postMock(Prefix + '/station/findPrivateStubList');
// 订单列表
const findOrderList = postMock(Prefix + '/order/findOrderList');
// 订单详情
const getOrderDetail = postMock(Prefix + '/order/getOrderDetail');
// 电站详情
const getStubGroupDetail = postMock(Prefix + '/station/getStubGroupDetail');
// 用户详情
const getUserInfo = postMock(Prefix + '/scUser/getUserInfo');
// 用户积分列表
const getUserIntergration = postMock(Prefix + '/scUser/getUserIntergration');
// 碳账户明细
const getUserCarbonInfo = postMock(Prefix + '/scUser/getUserCarbonInfo');
// 用户账户明细
const accountDetail = postMock(Prefix + '/scUser/accountDetail');
// 星币转换
const starCoinTransfer = postMock(Prefix + '/scUser/starCoinTransfer');
// 用户抵用券信息
const voucherList = postMock(Prefix + '/scUser/voucherList');
// 企业信息
const companyInfo = postMock(Prefix + '/scUser/companyInfo');
// 初始开票汇总信息
const inVoiceSummary = postMock(Prefix + '/invoice/summary');
// 申请开票
const applyInvoice = postMock(Prefix + '/invoice/apply');
// 发票列表
const invoiceList = postMock(Prefix + '/invoice/list');
// 发票详情
const invoiceInfo = postMock(Prefix + '/invoice/info');
// 过程数据
const processData = postMock(Prefix + '/order/processData');
// 企业密码重置
const companyInitPwd = postMock(Prefix + '/scUser/companyInitPwd');
// 阿里云日志列表
const aliLoglist = postMock(Prefix + '/log/aliGetLogs');
// 阿里云日志store
const alilogStore = getMock(Prefix + '/log/aliListLogstore');

// v1.2.0 api
// 私桩管理列表
const privateStubManager = postMock(Prefix + '/station/privateStubManager');
// 私桩类型列表
const privateTypeList = postMock(Prefix + '/station/privateType');
// 私桩订单列表
const findPrivateOrderList = postMock(Prefix + '/station/privateStubOrder');
// 故障告警列表
const findErrStubList = postMock(Prefix + '/station/findErrStubList');
// 故障码列表
const getErrorName = postMock(Prefix + '/station/getErrorName');
// 故障记录列表
const findErrStubRecord = postMock(Prefix + '/station/findErrStubRecord');
// 桩状态日志列表
const statusList = postMock(Prefix + '/station/statusList');

// v1.2.1
// 电站提示
const stubGroupNameTips = postMock(Prefix + '/station/stubGroupNameTips');
// 停止订单
const chargeStop = postMock(Prefix + '/order/chargeStop');
// 修改桩状态
const stubStatusSave = postMock(Prefix + '/stub/stubStatusSave');

// v1.2.2
// 固件升级列表查询
const frameWorkList = postMock(Prefix + '/stub/findFrameWorkList');
// 远程升级列表
const remoteUpdateList = postMock(Prefix + '/stub/findRemoteUpdateList');
// 获取固件型号，固件版本
const getTypeIdOrFrameWork = postMock(Prefix + '/stub/getTypeIdOrFrameWorkInfo');
// 电站查询
const findManagStubGroupList = postMock(Prefix + '/stub/findManagStubGroupList');
// 远程升级
const stubRemoteUpdate = postMock(Prefix + '/stub/stubRemoteUpdate');
// 修改固件状态
const updateFrameStatus = postMock(Prefix + '/stub/firmware/status/update');
// 上传固件
const uploadFrameWork = postMock(Prefix + '/stub/frameWorkUpload');
// 修改状态
const updateStubStatus = postMock(Prefix + '/stub/status/update');
// 升级履历列表
const findUpdateHistoryList = postMock(Prefix + '/stub/findUpdateHistoryList');
// 获取saas用户企业相关信息
const findSaasUserInfoList = postMock(Prefix + '/company/findSaasUserInfoList');
// 获取企业信息
const getCompanyInfo = postMock(Prefix + '/company/getCompanyInfo');
// 私桩预约订单
const findStubAppointmentList = postMock(Prefix + '/stub/findStubAppointmentList');
// 企业重置密码
const initCompanyPasswordSave = postMock(Prefix + '/company/initCompanyPasswordSave');
// 企业电站查询
const findDistinctStubList = postMock(Prefix + '/station/findDistinctStubList');
// 预约订单查看
const getStubAppointmentDetailInfo = postMock(Prefix + '/stub/getStubAppointmentDetailInfo');
// 绑定邮箱地址接口
const invoiceSend = postMock(Prefix + '/invoice/invoiceSend');
//用户需求收集表单信息列表查询
const userDemandList = postMock(Prefix + '/user/findUserDemandList');
//改变状态
const userStatusChange = postMock(Prefix + '/user/userStatusChange');
//填写跟进人
const addFollowUpPerson = postMock(Prefix + '/user/addFollowUpPerson');
//投资人列表
const investorList = postMock(Prefix + '/company/findInvestorList');
//商户列表
const contactList = postMock(Prefix + '/company/findContactList');
//禁止用户登录
const userLogin = postMock(Prefix + '/company/forbidUserLogin');
//重置密码
const initPassword = postMock(Prefix + '/company/investorInitPassword');
//添加投资人
const addInvestor = postMock(Prefix + '/company/addInvestor');
//下级商户
const contactLink = postMock(Prefix + '/company/findContactList');
//互联互通列表
const EVCSList = postMock(Prefix + '/evcs/list');
//互联互通新增编辑
const addevcs = postMock(Prefix + '/evcs/add');
//互联互通查询一条数据
const evcsConfig = postMock(Prefix + '/evcs/info');
//第三方开票参数配置
const webInvoiceConfig = postMock(Prefix + '/invoice/param/config');
//第三方结算参数配置
const webBalanceConfig = postMock(Prefix + '/balance/param/config');
//金融网关配置
const gateWayConfig = postMock(Prefix + '/gateway/config');
//互联互通配置信息新增修改
const evcsConfigInfoAdd = postMock(Prefix + '/evcs/config/add');
//互联互通配置信息查询单条数据
const evcsConfigGet = postMock(Prefix + '/evcs/config/get');
//互联互通数据权限列表
const dataPermissionList = postMock(Prefix + '/evcs/dataPermission/list');
//开票信息查询
const invoiceGet = postMock(Prefix + '/invoice/parem/get');
//网关参数获取
const balanceConfigGet = postMock(Prefix + '/balance/param/get');
//互联互通数据权限保存
const dataPermissionSave = postMock(Prefix + '/evcs/dataPermission/save');
//互联互通数据权限获取所有城市数据
const getCityName = postMock(Prefix + '/evcs/city/list');
//互联互通数据权限获取所有城市数据
const getStubName = postMock(Prefix + '/station/stubGroupName/get');
//互联互通数据权限获取所有城市数据
const importEvcsExcel = postMock(Prefix + '/import/evcs/excel');
// 固件列表
const stubFrameWorkList = postMock(Prefix + '/stub/frameWork/list');

// v1.3
// 根据桩id获取桩信息
const stubDetail = postMock(Prefix + '/workOrder/stubDetail/get');
// 获取故障码列表
const faultCodeList = postMock(Prefix + '/workOrder/faultCode/list');
// 获取故障类别列表
const faultTypeList = postMock(Prefix + '/workOrder/faultType/list');
// 获取erp用户列表
const erpUserList = postMock(Prefix + '/workOrder/user/list');
// 保存工单信息
const saveWorkOrder = postMock(Prefix + '/workOrder/save');
// 获取工单列表
// 回访工单
// 来电+1
const updateCallTimes = postMock(Prefix + '/workOrder/callTimes/update');
// 获取所有城市
const findCityList = postMock(Prefix + '/city/list');

//new
const appkeyEVCSList = postMock(Prefix + '/evcs/appkey/list');
// 互联互通-新增接口
const EVCSAdd= postMock(Prefix + '/evcs/appkey/save');
// 互联互通详情接口
const EVCSDetails=postMock(Prefix + '/evcs/appkey/info');
// 互联互通配置详情
const EVCSConfDetails=postMock(Prefix + '/evcs/cfg/info');
// 互联互通配置详情新增修改
const EVCSConfAdd=postMock(Prefix + '/evcs/cfg/save');
// 开票详情配置
const InvoiceDetails=postMock(Prefix + '/evcs/invoiceAppkeySetting/info');
//保存配置详情 evcs/invoiceAppkeySetting/save
const SaveInvoice=postMock(Prefix + '/evcs/invoiceAppkeySetting/save');
// 金融网关详情
const FinaceDetails=postMock(Prefix + '/evcs/appkeyServiceSetting/info');
// 金融网管新增
const FinaceAdd=postMock(Prefix + '/evcs/appkeyServiceSetting/save');
// 权限列表 evcs/role/list
const DataAuthList=postMock(Prefix + '/evcs/role/list');
// 工单列表
const workOrderList=postMock(Prefix + '/workOrder/list');
// 故障列表
const fcodeList =postMock(Prefix + '/workOrder/fcode/list');
// 客服
const workUserList =postMock(Prefix + '/workOrder/user/list');
// 更新来电次数
const CallTime=postMock(Prefix+'/workOrder/callTime/save');
// 添加回访 workOrder/returnVisit
const returnVisit=postMock(Prefix+'/workOrder/returnVisit');
// 保存工单 workOrder/save
const workOrderSaveApi=postMock(Prefix+'/workOrder/save');
//
const cityApi=postMock(Prefix+'/workOrder/area/list');
//workOrder/installAddress/info 工单获取地址
const cityApinstallAddressi=postMock(Prefix+'/workOrder/installAddress/info');
//workOrder/fcode/list
const fcodeListApi =postMock(Prefix+'/workOrder/fcode/list');
// evcs/role/save
const roleSave=getMock(Prefix+'/evcs/role/save');
// evcs/stubGroup/list
const stubGroupList=getMock(Prefix+'/evcs/stubGroup/list');
//evcs/area/provinceAndCity 获取城市
const getProAndCity=getMock(Prefix+'/evcs/area/provinceAndCity');
//evcs/appkey/idsList
const idsList=getMock(Prefix+'/evcs/appkey/idsList')
//evcs/cfg/status/update
const updateStatus=getMock(Prefix+'/evcs/cfg/status/update')
// evcs/stubGroup/import
const fileImport=getMock(Prefix+'/evcs/stubGroup/import');
//'/evcs/province/list'
const ApiPro=getMock(Prefix+'/evcs/province/list')
//const ApiPro=getMock(Prefix+'/evcs/province/list')
const ApiCity=getMock(Prefix+'/evcs/city/list')

//v1.4
// 删除用户
const userDelete = postMock(Prefix + '/user/delete');
// 获取发票对应的订单列表
const invoiceOrderList = postMock(Prefix + '/invoice/order/list');
// 获取电站列表
const stationList = postMock(Prefix + '/station/list');
// 获取用户组信息
const usergroupInfo = postMock(Prefix + '/company/info');
// 获取企业t+0信息
const usergroupTplus0Info = postMock(Prefix + '/company/payMethod/info');
// 保存企业t+0信息
const saveUsergroupTplus0 = postMock(Prefix + '/company/payMethod/save');
// 获取抵用券使用明细
const findVoucherUseDetail = postMock(Prefix + '/voucher/useDetail/list');
// 退款
const refund = postMock(Prefix + '/order/refund');
// 电桩配置参数查询
const stubCfgInfo = postMock(Prefix + '/stub/cfg/info');
// 电桩配置参数校验
const stubCfgCheck = postMock(Prefix + '/stub/cfg/cmd');
// 电桩配置操作履历
const stubCfgRecord = postMock(Prefix + '/stub/cfg/record');
// 电桩配置参数同步
const stubCfgSync = postMock(Prefix + '/stub/cfg/sync');
// 查询平台桩配置文件
const cfgFileList = postMock(Prefix + '/stub/cfg/file/list');
// 保存桩配置文件上传记录
const cfgFileSave = postMock(Prefix + '/stub/cfg/file/save');
// 删除桩配置文件上传记录
const cfgFileDelete = postMock(Prefix + '/stub/cfg/file/delete');
// 下发 平台桩配置文件
const platformCfgSave = postMock(Prefix + '/stub/cfg/save');

export {
    ApiCity,
    ApiPro,
    EVCSList,
    EVCSAdd,
    EVCSDetails,
    EVCSConfDetails,
    EVCSConfAdd,
    InvoiceDetails,
    SaveInvoice,
    FinaceDetails,
    FinaceAdd,
    DataAuthList,
    fcodeList,
    workUserList,
    CallTime,
    workOrderSaveApi,
    cityApi,
    cityApinstallAddressi,
    fcodeListApi,
    roleSave,
    stubGroupList,
    getProAndCity,
    idsList,
    updateStatus,
    fileImport,
  prefixFile,
  getUserMenuList,
  getPermissionList,
  editPermission,
  deletePermission,
  getSmsGroupList,
  getSmsInfoList,
  getRoleList,
  editRole,
  deleteRole,
  addSmsGroupInfo,
  sendSmsByGroupId,
  getUserList,
  getDDuserList,
  addUser,
  distributeRole,
  exchangeCode,
  fetchMap,
  chargingApplication,
  processChargeNumApply,
  errorCorrection,
  estimateManagment,
  buildingApply,
  processed,
  deleteCommend,
  replyCommend,
  findStubList,
  findPrivateStubList,
  findOrderList,
  getOrderDetail,
  getStubGroupDetail,
  getUserInfo,
  getUserIntergration,
  getUserCarbonInfo,
  accountDetail,
  starCoinTransfer,
  voucherList,
  companyInfo,
  inVoiceSummary,
  applyInvoice,
  invoiceList,
  invoiceInfo,
  processData,
  companyInitPwd,
  aliLoglist,
  alilogStore,
  privateStubManager,
  privateTypeList,
  findPrivateOrderList,
  findErrStubList,
  getErrorName,
  findErrStubRecord,
  statusList,
  frameWorkList,
  remoteUpdateList,
  stubGroupNameTips,
  chargeStop,
  stubStatusSave,
  getTypeIdOrFrameWork,
  findManagStubGroupList,
  stubRemoteUpdate,
  updateFrameStatus,
  uploadFrameWork,
  updateStubStatus,
  findUpdateHistoryList,
  findSaasUserInfoList,
  getCompanyInfo,
  findStubAppointmentList,
  initCompanyPasswordSave,
  findDistinctStubList,
  invoiceSend,
  getStubAppointmentDetailInfo,
    userDemandList,
	userStatusChange,
	addFollowUpPerson,
	investorList,
	contactList,
	userLogin,
	initPassword,
	addInvestor,
	contactLink,
    appkeyEVCSList,
    addevcs,
    evcsConfig,
    evcsConfigGet,
    webInvoiceConfig,
    webBalanceConfig,
    gateWayConfig,
    evcsConfigInfoAdd,
    dataPermissionList,
    invoiceGet,
    balanceConfigGet,
    dataPermissionSave,
    getCityName,
    getStubName,
    importEvcsExcel,
  stubFrameWorkList,
  stubDetail,
  faultCodeList,
  faultTypeList,
  erpUserList,
  saveWorkOrder,
  workOrderList,
  returnVisit,
  updateCallTimes,
  findCityList,
  userDelete,
  invoiceOrderList,
  stationList,
  usergroupInfo,
  usergroupTplus0Info,
  saveUsergroupTplus0,
  findVoucherUseDetail,
  refund,
  stubCfgInfo,
  stubCfgCheck,
  stubCfgRecord,
  stubCfgSync,
  cfgFileList,
  cfgFileSave,
  cfgFileDelete,
  platformCfgSave,
cancelReqs
}
